home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
FUTILS
/
FWRITE.DOC
< prev
next >
Wrap
Text File
|
1989-02-23
|
8KB
|
263 lines
/\ RKCP /\
\/ RKCP \/
********************************************************************
************************ FWRITE by Rex Kerr ************************
************************ Copyright (C) 1989 ************************
********************************************************************
This is a Turbo Pascal 5.0 unit written mostly in assembly
language. It has 12 routines for reading/writing and 7 that
affect how the 12 other routines work.
***
VramCh(x,y : byte; ch : char; attr : byte);
This writes the character ch in attribute attr at X,Y on the screen.
Note that VramCh pays no attention to any windows that might be
on the screen--all coordinates are absolute screen coordinates.
If you use the CRT unit in your program, you can write in the
current text color using the CRT variable TextAttr (like this:)
vramch(xpos,ypos,ch,textattr); { Only textattr needs to stay the same
to write in TP's text color }
***
GetVramCh(x,y : byte; var ch : char; attr : byte);
This reads the character and attribute at X,Y. See VramCh.
***
VramCharRpt(count : byte; x,y : byte; ch : char; attr : byte);
This works about the same as
procedure false_vramcharrpt(count,x,y : byte; ch : char; attr : byte);
var i : integer
begin
for i := 1 to count do vramch(x,y,ch,attr);
end;
except that VramCharRpt is much faster.
***
VramLineCopy(count : byte; x,y : byte; x2,y2 : byte);
This copies count characters (and attributes) starting at X,Y
and going to X2,Y2. It works about the same as
procedure false_vramlcopy(count,x,y,x2,y2 : byte);
var i,atr : byte;
ch : char;
begin
for i := 0 to count-1 do
begin
getvramch(x+i,y,ch,attr);
vramch(x2+i,y2,ch,attr);
end;
end;
except it is much much faster.
***
VramWrit(x,y : byte; attr : byte; st : string);
This writes the string st in attribute attr starting at X,Y.
It will NOT scroll the screen up when it goes off the end of the
last line.
***
ClrVramLine(line : byte; attr : byte);
This clears the line specified with the attribute specified.
***
ClrVram(attr : byte);
This clears the screen with the attribute specified.
***
VramScroll(lines : shortint; x,y,w,h : byte; attr : byte);
This scrolls the defined window (that is, a window the same size as
you would get with window(x,y,w,h); ) up the indicated number of
lines. New lines will be blank in the attribute attr. To scroll
the screen down, pass a negative number.
Note: To save speed, scroll as many lines as possible at one time.
Instead of writing
vramscroll(1,1,1,80,25,7);
vramwrit(1,25,7,'This is the');
vramscroll(1,1,1,80,25,7);
vramwrit(1,25,7,'slow way to');
vramscroll(1,1,1,80,25,7);
vramwrit(1,25,7,'scroll this.');
you should write
vramscroll(3,1,1,80,25,7);
vramwrit(1,23,7,'This is the');
vramwrit(1,24,7,'fast way to');
vramwrit(1,25,7,'do this.');
***
VramLine(x,y : byte; start,count : byte; var lin);
This is meant to write count chars and attrs (starting at X,Y on the
screen and start in lin) from the predefined type, vram_line, which
is defined as:
type vram_line = array[1..80][1..2] of byte;
in FWRITE.
However, you can pass any variable you want...but be sure you don't
overrun it.
***
GetVramLine(x,y : byte; start,count : byte; var lin);
This does the same thing as VramLine, except it reads into lin
instead of writing from it.
***
PutVramSec(var scrn; x,y,w,h : byte; x2,y2 : byte);
This is meant to copy a window on the screen (x,y,w,h) from scrn
(starting at x2,y2 in scrn). It is best explained through a demo,
so try running ftpudemo.exe.
***
GetVramSec(var scrn; x,y,w,h : byte; x2,y2 : byte);
This is putvramsec's twin. It does the same as putvramsec, except
it reads from the screen instead of writes to it.
***
Get_Display(var screenseg : word);
This returns $B000 if the monitor is monochrome, otherwise it
assumes CGA and returns $B800. It is normally used on the
variable Vid_Mem_Start. You can set Vid_Mem_Start yourself if
you want to write to an EGA or VGA display, for example.
Card Segment
Monochrome $B000
CGA $B800
EGA $A000
VGA $A000
***
SetVramOfs(ofst : word);
This sets the offset of screen memory. For the real screen, it
should always be 0. However, you may want to define a "fake" screen.
Assuming FakeBuf is an array at least 4000 bytes long, you can do
this to set up a fake screen to read from and write to:
vid_mem_start := seg(fakebuf);
setvramofs(ofs(fakebuf));
Now, all reads and writes will be to and from fakebuf, just like it
was the real screen. To write back to the old screen (assuming
Get_Display works for you) you simply do:
get_display(vid_mem_start);
setvramofs(0);
If get_display doesn't work, you'll have to save the old mode in
a variable:
var a : word;
b : vram_scrbuf;
begin
vid_mem_start := $A000; { You have an EGA in this example }
( . . . ) { Do some stuff }
a := vid_mem_start; { Save the address }
vid_mem_start := seg(b); { Set the segment address }
setvramofs(ofs(b)); { Set the offset address }
( . . . ) { Write to b instead of screen }
vid_mem_start := a; { Get the old address back again }
setvramofs(0); { Now you can write to the screen }
end.
***
GetVramOfs : word;
This gets the currently set offset. I never use this myself, but it
might be useful.
***
SetVramMaxX(lines : byte);
This sets the length of the lines on the screen. Useful for both
"fake" screens which are smaller (50*20, maybe) or EGA and VGA modes
where the lines are longer than normal.
***
GetVramMaxX : byte;
This gets the set length of the lines on the screen.
***
SetVramMaxY(lines : byte);
This sets the length of the screen in lines. It isn't really used
except in ClrVram. The others never check to see if they are going
off the end of the screen.
***
GetVramMaxY : byte;
This gets the set length of the screen in lines.
***
Two warnings:
1) FWRITE will cause snow on snowy CGAs. I haven't yet found out
how to not cause snow and not slow down good monitors too much.
2) FWRITE never checks to see that you have valid parameters. If
your screen is 80*25 and to do vramch(90,30,ch,textattr), It will
write the character out anyway. This is usually fine for the real
screen. However, when you are writing to a "fake" screen, you have
to be careful, because if you run over the end of the buffer, you
will most likely be overwriting something you didn't want to.
Also note that FWRITE never moves the cursor, and always reads from
absolute screen coordinates (i.e. 1,1 is always the top left corner
of the screen, even if you have done window(20,5,60,20)).
This is version 0.7 of FWRITE. It hasn't made it to 1.0 yet
because it still causes snow (I think) and can't detect EGA or
VGA.
If I've neclected to mention something, or if anything is unclear,
please contact using either EasyPlex or BPROGA's TP5 message
section.
Rex Kerr 71550,3147
/\ RKCP /\
\/ RKCP \/